*Figure 4: Cash Withdrawals Near Term
clear all 
use figure4_nt

gen avg = .
gen inter = . 

forvalues i = 0(1)24 { 
local c = `i' + 1
quietly sum delta_nfs_totalamount if dist_cc >= `i' & dist_cc < `c'
replace avg = r(mean) if dist_cc >= `i' & dist_cc < `c'
replace inter = (`i' + `c')/2 if dist_cc >= `i' & dist_cc < `c'
} 

duplicates drop inter, force
drop if avg == .

scatter avg inter if inter || lfit avg inter , msize(vsmall) graphregion(color(white)) ///
ytitle("Difference (Log)", height(5)) legend(off) xtitle("Distance to Currency Chest (km)", height(5)) subtitle("Cash Withdrawals" "Near-Term") ylabel(#3)

drop avg inter

*Figure 4: Digital Payments Near Term

gen avg = .
gen inter = . 

forvalues i = 0(1)24 { 
local c = `i' + 1
quietly sum delta_pos_totalamount if dist_cc >= `i' & dist_cc < `c'
replace avg = r(mean) if dist_cc >= `i' & dist_cc < `c'
replace inter = (`i' + `c')/2 if dist_cc >= `i' & dist_cc < `c'
} 

duplicates drop inter, force
drop if avg == .

scatter avg inter || lfit avg inter, msize(vsmall) graphregion(color(white)) ///
ytitle("Difference (Log)", height(5)) legend(off) xtitle("Distance to Currency Chest (km)", height(5)) subtitle("Digital Transactions" "Near-Term") ylabel(#3)

*Figure 4: Cash Withdrawals Long Term

clear all 
use figure4_lt

gen avg = .
gen inter = . 

forvalues i = 0(1)24 { 
local c = `i' + 1
quietly sum delta_nfs_totalamount if dist_cc >= `i' & dist_cc < `c'
replace avg = r(mean) if dist_cc >= `i' & dist_cc < `c'
replace inter = (`i' + `c')/2 if dist_cc >= `i' & dist_cc < `c'
} 

duplicates drop inter, force
drop if avg == .

scatter avg inter || lfit avg inter, msize(vsmall) graphregion(color(white)) ///
ytitle("Difference (Log)", height(5)) legend(off) xtitle("Distance to Currency Chest (km)", height(5)) subtitle("Cash Withdrawals" "Long-Term") ylabel(#3)

drop avg inter

*Figure 4: Digital Payments Long Term

gen avg = .
gen inter = . 

forvalues i = 0(1)24 { 
local c = `i' + 1
quietly sum delta_pos_totalamount if dist_cc >= `i' & dist_cc < `c'
replace avg = r(mean) if dist_cc >= `i' & dist_cc < `c'
replace inter = (`i' + `c')/2 if dist_cc >= `i' & dist_cc < `c'
} 

duplicates drop inter, force
drop if avg == .

scatter avg inter || lfit avg inter, msize(vsmall) graphregion(color(white)) ///
ytitle("Difference (Log)", height(5)) legend(off) xtitle("Distance to Currency Chest (km)", height(5)) subtitle("Digital Transactions" "Long-Term") ylabel(#3)
